package com.jingdong.dao.address.impl;

import com.jingdong.dao.address.OrderAddressDao;
import com.jingdong.model.Order_address;
import com.jingdong.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class OrderAddressDaoImpl implements OrderAddressDao {
    @Override
    public int save(Order_address order_address) {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            int svaeResult=sqlSession.insert("com.jingdong.orderAddressModel.save",order_address);
            sqlSession.commit();
            sqlSession.close();
            return svaeResult;
        }catch (Exception   e){
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public List<Order_address> addressList(int uid) {
        try{
            SqlSession sqlSession= MyBatisUtils.getSqlSession();
            List<Order_address> list=sqlSession.selectList("com.jingdong.orderAddressModel.list",uid);
            sqlSession.close();
            return list;
        }catch (Exception   e){
            e.printStackTrace();
        }
        return null;
    }
}
